package cn.ffcs.contract.dao;

import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import org.springframework.orm.hibernate3.HibernateCallback;

import cn.ffcs.base.dao.BaseDAO;
import cn.ffcs.base.web.PageControl;
import cn.ffcs.contract.model.ContractRecord;

/**
 * 
 * 合同DAO实现<br/> <table>
 * <tr>
 * <td>负责人/principal: </td>
 * <td colspan="2">pany</td>
 * <tr>
 * <td>修改记录/revision:</td>
 * <td colspan="2"></td>
 * </tr>
 * <tr>
 * <td>日期:</td>
 * <td>修改人:</td>
 * <td>修改说明:</td>
 * </tr>
 * <tr>
 * <td></td>
 * <td></td>
 * <td></td>
 * </tr>
 * </table>
 * @author pany
 * @version $Id$
 */
public class ContractRecordDAO<D extends ContractRecord> extends BaseDAO<D> implements
        IContractRecordDAO<D>
{
    /**
     * 获取实体类
     * @param b
     * @return
     */
    public String getEntityName()
    {
        return new ContractRecord().getClass().getName();
    }

    /**
     * 根据参数和参数值直接删除对应条件数据
     * @param entity
     * @param param
     * @param paramValue
     */
    public void remove(Object entity, String param, String paramValue)
    {
        final String fParam = param;
        final String fParamValue = paramValue;
        final String fEntityName = getEntityName();

        getHibernateTemplate().execute(new HibernateCallback()
        {
            public Object doInHibernate(Session session)
                    throws HibernateException
            {
                String hql = "delete from " + fEntityName + " where " + fParam
                        + " = '" + fParamValue + "'";
                
                session.createQuery(hql).executeUpdate();
                return true;
            }
        });
    }
    
}
